/**
 * 
 */
package net.ddns.heroli.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.gzheroli.core.common.model.json.AjaxJson;

/**  
* 类名: GlobalExceptionHandler  
* 描述: TODO(这里用一句话描述这个类的作用)  
* 作者: 李长荣 lichang_20011@163.com  
* 日期: 2017年12月21日  下午3:45:17
*@version V1.0  
*    
*/
//@ControllerAdvice
public class GlobalExceptionHandler {
	private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/*
    @ExceptionHandler(NotAuthorizedException.class)
    public @ResponseBody  handleNotAuthorizedException(Exception e) {
        logger.error(e.getMessage(), e);
        return new ErrorMessage(e.getLocalizedMessage());
    }
    @ExceptionHandler(ForbiddenException.class)
    @ResponseBody
    public  AjaxJson handleForbiddenException(Exception e) {
        logger.error(e.getMessage(), e);
        return new ErrorMessage(e.getLocalizedMessage());
    }

    @ExceptionHandler(DataAccessException.class)
    public @ResponseBody AjaxJson handleDataAccessException(Exception e) {
        logger.warn(e.getMessage(), e);
        return new ErrorMessage("数据访问错误: " + e.getLocalizedMessage());
    }

    //@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    @ExceptionHandler(HttpAccessException.class)
    public @ResponseBody AjaxJson handleHttpAccessException(Exception e) {
        logger.warn(e.getMessage(), e);
        return new ErrorMessage("访问外部服务错误: " + e.getLocalizedMessage());
    }

   // @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public  AjaxJson handleException(Exception e) {
        logger.warn(e.getMessage(), e);
        return new ErrorMessage("系统内部错误: " + e.getLocalizedMessage());
    }*/
}
